package geral.manager;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.Conversation;
import javax.inject.Inject;
import javax.inject.Named;

@Named
public class GenericManager{
	
	@Inject
	private Conversation conversation;
	
	@PostConstruct
	public void init(){
		if (conversation.isTransient()){
			conversation.setTimeout(600000);
			conversation.begin();
			
		}
	}
	
	@PreDestroy
	@Override
	protected void finalize() throws Throwable {
		conversation.end();
		super.finalize();
	}
	
	public void end(){
		conversation.end();
	}

}
